﻿<!DOCTYPE html>
<html>
	<head>
		<title>链接列表</title>
    $css()$js()
	</head>
	<body>
    <div class="_tabarea">
    <!--
    <div class="tab_mini">
        <a href="?module=link&amp;action=create">添加链接</a>
        <a href="?module=link&amp;action=list&amp;type=navigation" class="btnlink">栏目链接</a>
        <a href="?module=link&amp;action=list&amp;type=customlink" class="btnlink">自定义链接</a>
        <a href="?module=link&amp;action=list&amp;type=friendlink" class="btnlink">友情链接</a>
    </div>
    -->
 <table class="ui-table" cellspacing="0" cellpadding="0" id="links">
    <tr><th class="hidden">ID</th>
      <th style="width:50px;">编号</th>
      <th style="width:200px">链接名称</th>
      <th>链接</th>
      <th style="width:100px;text-align:center">打开目标</th>
      <th width="40">顺序</th>
      <th width="90">显示/隐藏</th>
      <th width="60">修改</th>
      <th width="60">删除</th>
    </tr>

    ${linkRowsHtml}
     
  </table>
    <div class="ui-table-meta"><span class="left tleft createlink"><a href="?module=link&action=create&type=${linktype}">创建一个新的链接</a></span>共${count}</div>
</div>

    <script type="text/javascript">

        var tablinks = document.getElementsByClassName('btnlink');
        for (var i = 0; i < tablinks.length; i++) {
            if(location.href.indexOf(tablinks[i].href.replace(/&amp;/,'$')) !=-1){
                tablinks[i].className='current';
            }
        }

    cms.table.dynamic(document.getElementsByTagName('TABLE')[0]);

     var bts = cms.$("links", "button");
     for(var i=0;i<bts.length;i++){
       bts[i].onclick = (function (t) {
         return function () {
           var id = t.parentNode.parentNode.getElementsByTagName('td')[0].innerHTML;
           switch (t.className) {
             case "delete del":
               (function () {
                 if (confirm('确定删除吗?')) {
                   var tr = t.parentNode.parentNode;
                   cms.xhr.post('?', 'module=link&action=delete&linkID=' + id,
                        function () { tr.style.display = 'none'; },
                         function (x) { alert(x); });
                 }
               })();
               break;

             case "edit": case "save":
               (function () {
                 location.replace('?module=link&action=edit&linkid=' + id);
               })();
               break;

             case "ok": case 'delete':
               (function () {
                 cms.xhr.post('?', 'module=link&action=setvisible&linkID=' + id,
                 function () { t.className = t.className != 'ok' ? 'ok' : 'delete'; },
                 function (x) { alert(x); });
               })();
               break;
           }
         };
       })(bts[i]);
     }

     function tip() {alert('x');}
  </script>

	</body>
</html>